<template>
    <div>
        <!-- 搜索 -->
        <Search ref="search" :fields="searchItem" :search="getList"></Search>
        <!-- 列表 -->
        <DataTable v-loading="listLoading" :list="list" :fields="fields"
            :permissions="$store.state.permissions" :add="toSave" :edit="toSave"
            :del="del" :batchDel="batchDel">
            <template slot="buttonSlot" slot-scope="scope">
                <el-tooltip content="预览" class="operatingButton">
                    <el-link type="primary" icon="el-icon-view" :underline="false" @click="preview(scope.row)">
                    </el-link>
                </el-tooltip>
                <el-tooltip content="生成页面" class="operatingButton" v-if="$store.state.permissions.insert">
                    <el-link type="primary" icon="el-icon-link" :underline="false" @click="generatePage(scope.row)">
                    </el-link>
                </el-tooltip>
            </template>
        </DataTable>
        <!-- 分页 -->
        <el-pagination style="float:right;margin-top: 10px;" background layout="total, sizes, prev, pager, next"
            :page-sizes="[5, 10, 15, 30]" :page-size="pageSize" :total="total" @current-change="changePage"
            @size-change="changeSize">
        </el-pagination>

        <!-- 表单 -->
        <Form :title="title" :visible.sync="formVisible" :fields.sync="formFields" :formData="formData"
            :submitForm="save" width="80%">
            <template slot="fieldsSlot">
                <el-form-item label="查询项">
                    <el-tag style="margin-right: 5px;" v-for="(tag, index) in listJson.searchFields" :key="tag.name" closable
                        @close="removeConfig('search', index)">
                        {{ tag.name }}
                    </el-tag>
                </el-form-item>
                <el-form-item label="列表项">
                    <el-tag style="margin-right: 5px;" v-for="(tag, index) in listJson.listFields" :key="tag.name" closable
                        @close="removeConfig('list', index)">
                        {{ tag.name }}
                    </el-tag>
                </el-form-item>
                <el-form-item label="表单项">
                    <el-tag style="margin-right: 5px;" v-for="(tag, index) in listJson.formFields" :key="tag.name" closable
                    @close="removeConfig('form', index)">
                        {{ tag.name }}
                    </el-tag>
                </el-form-item>
                <el-form-item label="排序项">
                    <el-tag style="margin-right: 5px;" v-for="(tag, index) in listJson.sortFields" :key="tag.name" closable
                        @close="removeConfig('sort', index)">
                        {{ tag.name }}
                    </el-tag>
                    <el-tag v-if="!listJson.sortFields || listJson.sortFields.length==0" type="info">
                        如不选择排序项，将默认以 `创建时间(create_time)` 进行倒序排序
                    </el-tag>
                </el-form-item>
                <el-table v-loading="optionalFieldsLoading" :data="optionalFields" :header-cell-style="headStyle" :cell-style="rowStyle"
                    style="width: 100%">
                    <el-table-column label="字段名称" prop="fieldName" />
                    <el-table-column label="字段编码" prop="fieldCode" />
                    <el-table-column label="操作">
                        <template slot-scope="scope">
                            <el-link type="primary" icon="el-icon-circle-plus-outline"
                                v-if="scope.row.fieldCode != 'del'"
                                @click="openAddConfigForm(scope.row, 'search')" style="margin: 0 8px;">查询</el-link>
                            <el-link type="primary" icon="el-icon-circle-plus-outline"
                                v-if="scope.row.fieldCode != 'del'"
                                @click="openAddConfigForm(scope.row, 'list')" style="margin: 0 8px;">列表</el-link>
                            <el-link type="primary" icon="el-icon-circle-plus-outline"
                                v-if="scope.row.fieldCode != 'uuid' && scope.row.fieldCode != 'create_time' && scope.row.fieldCode != 'update_time' && scope.row.fieldCode != 'del'"
                                @click="openAddConfigForm(scope.row, 'form')" style="margin: 0 8px;">表单</el-link>
                            <el-link type="primary" icon="el-icon-circle-plus-outline"
                                v-if="scope.row.fieldCode != 'del'"
                                @click="openAddConfigForm(scope.row, 'sort')" style="margin: 0 8px;">排序</el-link>
                            <span v-if="scope.row.fieldCode == 'del'">此项不可进行任何操作！</span>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
        </Form>

        <!-- 添加配置项的表单 -->
        <Form :title="addConfigTitle" :visible.sync="addConfigVisible" :fields.sync="addConfigFields"
            :formData="addConfigForm" :submitForm="addConfig" width="45%">
        </Form>

        <!-- 数据页面预览 -->
        <el-dialog title="页面预览" :visible.sync="previewVisible" width="83%" :before-close="cancelPreview"
            :destroy-on-close="true" :close-on-click-modal="false">
            <Search v-if="previewSearchFields.length > 0" :fields="previewSearchFields" :search="previewButton">
            </Search>
            <DataTable v-loading="previewLoading" :list="previewList" :fields="previewListFields"
                :permissions="$store.state.permissions" :add="previewInsertButton"
                :edit="previewButton" :del="previewButton" :exports="previewButton">
            </DataTable>
            <Form title="新增" :modal="false" :visible.sync="previewFormVisible" :fields.sync="previewFormFields" :formData="previewFormData"
                :submitForm="previewButton">
            </Form>
        </el-dialog>

        <!-- 生成菜单 -->
        <Form title="生成菜单" :visible.sync="generateVisible" :fields.sync="generateFromFields" :formData="generateForm"
            :submitForm="generate">
        </Form>

    </div>
</template>

<script>

export default {
    data() {
        return {
            // 搜索字段
            searchItem: [
                {
                    label: "数据对象",
                    value: "obj_code",
                    operator: "like"
                }
            ],
            // 表格字段
            fields: [
                {
                    label: "页面唯一标识",
                    value: "uuid",
                },
                {
                    label: "页面名称",
                    value: "page_name",
                },
                {
                    label: "创建时间",
                    value: "create_time",
                }
            ],
            // 表格数据
            list: [],
            // 表格loading开关
            listLoading: false,
            // 分页数据
            pageNum: 1,
            pageSize: 10,
            total: 0,

            // 表单表头
            title: "",
            // 表单开关
            formVisible: false,
            // 表单字段
            formFields: [
                {
                    label: "数据对象",
                    value: "obj_code",
                    type: "selector",
                    options: [],
                    optionsLabel: "objName",
                    optionsValue: "objCode",
                    rules: [{ required: true, message: "数据对象不能为空!" }],
                },
                {
                    label: "页面名称",
                    value: "page_name",
                    rules: [{ required: true, message: "页面名称不能为空!" }],
                },
                {
                    label: "是否开启部门数据隔离",
                    value: "enable_data_isolation",
                    type: "radio",
                    options: [
                        {
                        label: "开启",
                        value: 1,
                        },
                        {
                        label: "关闭",
                        value: 0,
                        }
                    ],
                    rules: [{ required: true, message: "是否开启部门数据隔离不能为空!" }],
                },
            ],
            // 表单数据
            formData: {},

            // 数据对象字段数据
            optionalFields: [],
            optionalFieldsLoading: false,
            // 修改初始化数据对象字段数据开关
            updateInit: false,

            // 页面预览开关
            previewVisible: false,
            // 页面预览加载开关
            previewLoading: false,
            // 页面预览表格数据
            previewList: [],
            // 页面预览表格字段
            previewListFields: [],
            // 页面预览搜索字段
            previewSearchFields: [],
            // 页面预览表单字段
            previewFormFields: [],
            // 页面预览表单开关
            previewFormVisible: false,
            previewFormData: {},

            // 生成页面表单开关
            generateVisible: false,
            // 生成页面表单字段
            generateFromFields: [
                {
                    label: "父级菜单",
                    value: "parentId",
                    type: "cascader",
                    options: [],
                    rules: [{ required: true, message: "父级菜单不能为空!" }],
                },
                {
                    label: "菜单名称",
                    value: "menuName",
                    rules: [{ required: true, message: "菜单名称不能为空!" }],
                },
                {
                    label: "菜单图标",
                    value: "menuIcon",
                    type: "icon",
                },
                {
                    label: "排序",
                    value: "sort",
                    type: "number",
                },
            ],
            // 生成页面表单数据
            generateForm: {},

            addConfigVisible: false,
            addConfigTitle: "",
            addConfigFields: [],
            addConfigForm: {},

            listJson: {
                searchFields: [],
                listFields: [],
                formFields: [],
                sortFields: [],
            }
        }
    },
    mounted() {
        this.getBaseObjList();
        this.getList();
    },
    watch: {
        // 修改数据对象时的操作
        watchFromData: {
            handler(objCode) {
                if (objCode) {
                    this.getObjFieldList(objCode)
                }
            }
        }
    },
    computed: {
        watchFromData() {
            return this.formData.obj_code
        }
    },
    methods: {
        // 删除配置项
        removeConfig(type,index) {
            switch(type){
                case "search":
                    this.listJson.searchFields.splice(index, 1)
                    break;
                case "list":
                    this.listJson.listFields.splice(index, 1)
                    break;
                case "form":
                    this.listJson.formFields.splice(index, 1)
                    break;
                case "sort":
                    this.listJson.sortFields.splice(index, 1)
                    break;
            }
        },
        // 添加查询项，添加列表项，添加表单项，添加排序项
        openAddConfigForm(row, type) {
            switch (type) {
                case 'search':
                    this.addConfigTitle = "添加为查询项";
                    this.addConfigFields = [
                        {
                            label: "查询类型",
                            value: "operator",
                            type: "selector",
                            options: this.getSelectType(),
                        },
                        {
                            label: "显示顺序",
                            value: "sort",
                            type: "number",
                        },
                    ];
                    this.addConfigForm = {
                        fieldName: row.fieldName,
                        fieldCode: row.fieldCode,
                        correlatedBaseObjCode: row.correlatedBaseObjCode,
                        correlatedBaseObjFieldCode: row.correlatedBaseObjFieldCode,
                        isBaseObj: row.isBaseObj,
                        addConfigType: type,
                        type: "string",
                        sort: 0,
                        operator: "="
                    }
                    if(row.isBaseObj){
                        this.addConfigFields[0].disabled = true;
                        this.addConfigForm.type = "selector";
                    }
                    break;
                case 'list':
                    this.addConfigTitle = "添加为列表项";
                    this.addConfigFields = [
                        {
                            label: "展示方式",
                            value: "listType",
                            type: "selector",
                            options: this.getListType(),
                        },
                        {
                            label: "显示顺序",
                            value: "sort",
                            type: "number",
                        },
                    ];
                    this.addConfigForm = {
                        fieldName: row.fieldName,
                        fieldCode: row.fieldCode,
                        addConfigType: type,
                        sort: 0,
                        listType: "string"
                    }
                    break;
                case "form":
                    this.addConfigTitle = "添加为表单项";
                    this.addConfigFields = [
                        {
                            label: "控件类型",
                            value: "type",
                            type: "selector",
                            disabled:false,
                            options: this.getFormType()
                        },
                        {
                            label: "是否必填",
                            value: "required",
                            type: "radio",
                            options:[
                                {
                                    label: "必填",
                                    value: true,
                                },
                                {
                                    label: "非必填",
                                    value: false,
                                },
                            ]
                        },
                        {
                            label: "显示顺序",
                            value: "sort",
                            type: "number",
                        },
                    ];
                    this.addConfigForm = {
                        fieldName: row.fieldName,
                        fieldCode: row.fieldCode,
                        correlatedBaseObjCode: row.correlatedBaseObjCode,
                        correlatedBaseObjFieldCode: row.correlatedBaseObjFieldCode,
                        isBaseObj: row.isBaseObj,
                        addConfigType: type,
                        type: "string",
                        required: false,
                        sort: 0,
                    }
                    if(row.isBaseObj){
                        this.addConfigFields[0].disabled = true;
                        this.addConfigForm.type = "selector";
                    }
                    break;
                case 'sort':
                    this.addConfigTitle = "添加为排序项";
                    this.addConfigFields = [
                        {
                            label: "排序方式",
                            value: "sortType",
                            type: "selector",
                            options: this.getSortType(),
                        }
                    ];
                    this.addConfigForm = {
                        fieldName: row.fieldName,
                        fieldCode: row.fieldCode,
                        addConfigType: type,
                        sortType: "ASC"
                    }
                    break;
            }
            this.addConfigVisible = true;
        },
        // 确认添加
        addConfig() {
            switch (this.addConfigForm.addConfigType) {
                case 'search':
                    this.addSearchConfig(); break;
                case 'list':
                    this.addListConfig(); break;
                case "form":
                    this.addFormConfig(); break;
                case "sort":
                    this.addSortConfig(); break;
            }
            this.addConfigVisible = false;
        },
        // 添加搜索字段
        addSearchConfig() {
            let searchField = {
                name: this.addConfigForm.sort + ". " + this.addConfigForm.fieldName + "(" + this.getSelectType(this.addConfigForm.operator) + ")",
                fieldName: this.addConfigForm.fieldName,
                fieldCode: this.addConfigForm.fieldCode,
                correlatedBaseObjCode: this.addConfigForm.correlatedBaseObjCode,
                correlatedBaseObjFieldCode: this.addConfigForm.correlatedBaseObjFieldCode,
                isBaseObj: this.addConfigForm.isBaseObj,
                type: this.addConfigForm.type,
                operator: this.addConfigForm.operator,
                sort: this.addConfigForm.sort,
            };
            let flag = false;
            this.listJson.searchFields.forEach(e => {
                if (e.fieldCode == this.addConfigForm.fieldCode) {
                    flag = true;
                }
            })
            if (!flag) {
                this.listJson.searchFields.push(searchField);
            }else{
                this.$message.warning("此项已存在！")
            }
        },
        // 添加列表字段
        addListConfig() {
            let listField = {
                name: this.addConfigForm.sort + ". " + this.addConfigForm.fieldName + "(" + this.getListType(this.addConfigForm.listType) + ")",
                fieldName: this.addConfigForm.fieldName,
                fieldCode: this.addConfigForm.fieldCode,
                listType: this.addConfigForm.listType,
                sort: this.addConfigForm.sort,
            };
            let flag = false;
            this.listJson.listFields.forEach(e => {
                if (e.fieldCode == this.addConfigForm.fieldCode) {
                    flag = true;
                }
            })
            if (!flag) {
                this.listJson.listFields.push(listField);
            }else{
                this.$message.warning("此项已存在！")
            }
        },
        // 添加表单字段
        addFormConfig() {
            let formField = {
                name: this.addConfigForm.sort + ". " + this.addConfigForm.fieldName + "(" + this.getFormType(this.addConfigForm.type) + ")",
                fieldName: this.addConfigForm.fieldName,
                fieldCode: this.addConfigForm.fieldCode,
                correlatedBaseObjCode: this.addConfigForm.correlatedBaseObjCode,
                correlatedBaseObjFieldCode: this.addConfigForm.correlatedBaseObjFieldCode,
                isBaseObj: this.addConfigForm.isBaseObj,
                type: this.addConfigForm.type,
                required: this.addConfigForm.required,
                sort: this.addConfigForm.sort,
            };
            let flag = false;
            this.listJson.formFields.forEach(e => {
                if (e.fieldCode == this.addConfigForm.fieldCode) {
                    flag = true;
                }
            })
            if (!flag) {
                this.listJson.formFields.splice(formField.sort,0,formField);
            }else{
                this.$message.warning("此项已存在！")
            }
        },
        // 添加排序字段
        addSortConfig() {
            let sortField = {
                name: this.addConfigForm.fieldName + "(" + this.getSortType(this.addConfigForm.sortType) + ")",
                fieldName: this.addConfigForm.fieldName,
                fieldCode: this.addConfigForm.fieldCode,
                sortType: this.addConfigForm.sortType,
            };
            let flag = false;
            this.listJson.sortFields.forEach(e => {
                if (e.fieldCode == this.addConfigForm.fieldCode) {
                    flag = true;
                }
            })
            if (!flag) {
                this.listJson.sortFields.push(sortField);
            }else{
                this.$message.warning("此项已存在！")
            }
        },
        // 提交生成
        generate() {
            this.$api.baseListConfig.generatePage(this.generateForm).then(res => {
                if (res.code == 200) {
                    this.generateVisible = false;
                    this.$emit('getMenuTree');
                    this.$message.success("操作成功！");
                } else {
                    this.$message.error(res.msg);
                }
            })
        },
        // 获取菜单列表
        getMenuList() {
            this.$api.menu.getList().then((res) => {
                if (res.code == 200) {
                    this.generateFromFields[0].options = [
                        {
                            value: "0",
                            label: "主类目",
                            children: this.buildOptions(res.data),
                        },
                    ];
                } else {
                    this.$message.error(res.msg);
                }
            });
        },
        // 构建联级选择数据
        buildOptions(menuList) {
            let list = [];
            menuList.forEach((e) => {
                if(e.menuType == 0){
                    let options = {};
                    options["value"] = e.uuid;
                    options["label"] = e.menuName;
                    if (e.childMenus && e.childMenus.length != 0) {
                        options["children"] = this.buildOptions(e.childMenus);
                    }
                    list.push(options);
                }
            });
            return list;
        },
        // 打开生成页面
        generatePage(row) {
            this.generateForm['uuid'] = row.uuid;
            this.generateForm['objCode'] = row.obj_code;
            this.getMenuList();
            this.generateVisible = true;
        },
        // 预览页面的按钮效果
        previewButton() {
            this.$message.warning("预览页面不允许操作！")
        },
        // 预览页面的新增按钮
        previewInsertButton(){
            this.previewFormVisible = true;
            console.log(this.previewFormFields);
        },
        // 预览
        preview(row) {
            this.previewLoading = true;
            this.previewSearchFields = [];
            this.previewListFields = [];
            this.$api.baseListConfig.getConfigByUuid(row.uuid).then(res => {
                if (res.code == 200) {
                    this.previewSearchFields = res.data.searchFields;
                    this.previewListFields = res.data.listFields;
                    this.previewFormFields = res.data.formFields;
                    let previewObj = {};
                    res.data.listFields.forEach(e => {
                        switch (e.type) {
                            case 'boolean':
                                previewObj[e.value] = true;
                                break;
                            default: previewObj[e.value] = "xxx";
                        }
                    })
                    this.previewList = [];
                    this.previewList.push(previewObj);
                }
                this.previewLoading = false;
            })
            this.previewVisible = true;
        },
        // 关闭预览
        cancelPreview() {
            this.previewVisible = false;
        },
        // 保存方法
        save() {
            this.formData.field_list = JSON.stringify(this.listJson);
            let vo = {
                objectCode: 'base_list_config',
                fields: [],
                conditions: [],
            }
            for (let key in this.formData) {
                if (key == 'uuid' || key == 'create_time' || key == 'update_time' || key == 'del') {
                    continue;
                }
                vo.fields.push({
                    fieldCode: key,
                    value: this.formData[key],
                })
            }
            if(this.formData['uuid']){
                vo.conditions.push({
                    fieldCode: "uuid",
                    operator: "=",
                    value: this.formData['uuid']
                });
            }
            this.$api.baseData.save(vo).then(res => {
                if (res.code == 200) {
                    this.$message.success("操作成功")
                    this.formVisible = false;
                    this.$refs.search.search(this.$refs.search.param);
                } else {
                    this.$message.error(res.msg)
                    this.$refs.form.saveLoading = false;
                }
            })
        },
        // 删除
        del(uuid) {
            let vo = {
                objectCode: 'base_list_config',
                conditions: [
                    {
                        fieldCode: "uuid",
                        operator: "=",
                        value: uuid,
                    }
                ]
            }
            this.$api.baseData.del(vo).then(res => {
                if (res.code == 200) {
                    this.$message.success(res.msg);
                    this.$refs.search.search(this.$refs.search.param);
                } else {
                    this.$message.error(res.msg);
                }
            })
        },
        // 批量删除
        batchDel(uuids) {
            let vo = {
                objectCode: 'base_list_config',
                conditions: [
                    {
                        fieldCode: "uuid",
                        operator: "in",
                        value: uuids,
                    }
                ]
            }
            this.$api.baseData.del(vo).then(res => {
                if (res.code == 200) {
                    this.$message.success(res.msg);
                    this.$refs.search.search(this.$refs.search.param);
                } else {
                    this.$message.error(res.msg);
                }
            })
        },
        // 打开新增|修改
        toSave(uuid) {
            this.optionalFields = [];
            this.listJson = {
                searchFields: [],
                listFields: [],
                formFields: [],
                sortFields: [],
            }
            this.formData = {};
            if (uuid) {
                let vo = {
                    objectCode: 'base_list_config',
                    uuid: uuid
                }
                this.$api.baseData.detail(vo).then(res => {
                    if (res.code == 200) {
                        this.formData = res.data;
                        this.listJson = JSON.parse(res.data.field_list);
                        this.updateInit = true;
                    }
                })
                this.title = "修改数据页面配置"
            } else {
                this.title = "新增数据页面配置"
            }
            this.formVisible = true;
        },
        // 获取数据页面配置
        getList(param) {
            this.listLoading = true;
            let vo = {
                objectCode: 'base_list_config',
                page: {
                    page: true,
                    pageNum: this.pageNum,
                    pageSize: this.pageSize
                },
                conditions: [],
            }
            if (param) {
                this.searchItem.forEach(e => {
                    let fieldCode = e.value
                    let operator = e.operator
                    let value = param[e.value]
                    if (value) {
                        value = operator && operator == 'like' ? "%" + value + "%" : value
                        vo.conditions.push({ fieldCode: fieldCode, operator: operator, value: value })
                    }
                })
            }
            this.$api.baseData.list(vo).then(res => {
                if (res.code == 200) {
                    this.list = res.data.list;
                    this.pageNum = res.data.pageNum;
                    this.total = res.data.total;
                }
                this.listLoading = false;
            })
        },
        // 获取数据对象列表
        getBaseObjList() {
            let param = {
                pageNum: 1,
                pageSize: 99999,
            }
            this.$api.baseObj.list(param).then(res => {
                if (res.code == 200) {
                    this.formFields[0].options = res.data.list;
                }
            })
        },
        // 获取数据对象字段列表
        getObjFieldList(objCode) {
            this.optionalFieldsLoading = true;
            if (!this.updateInit) {
                this.optionalFields = [];
            }
            let vo = {
                objectCode: 'base_obj_field',
                conditions: [
                    {
                        fieldCode: "obj_code",
                        operator: "=",
                        value: objCode,
                    }
                ],
                sorts: [
                    {
                        fieldCode: "create_time",
                        sortType: "ASC"
                    }
                ]
            }
            this.$api.baseData.list(vo).then(res => {
                if (res.code == 200) {
                    let newOptionalFields = [];
                    res.data.list.forEach(e => {
                        let optionalField = {
                                fieldName: e.field_name,
                                fieldCode: e.field_code,
                                isBaseObj: e.is_base_obj,
                                correlatedBaseObjCode: e.correlated_base_obj_code,
                                correlatedBaseObjFieldCode:e.correlated_base_obj_field_code,
                            }
                        newOptionalFields.push(optionalField)
                    })
                    if (this.updateInit) {
                        let newArr = newOptionalFields.filter(e1 => {
                            return this.optionalFields.every(e2 => {
                                return e1.fieldCode != e2.fieldCode;
                            })
                        })
                        this.optionalFields = this.optionalFields.concat(newArr);
                        this.updateInit = false;
                    } else {
                        this.optionalFields = newOptionalFields
                    }
                }
                this.optionalFieldsLoading = false;
            })
        },
        // 切换每页大小
        changeSize(pageSize) {
            this.pageSize = pageSize;
            this.$refs.search.search(this.$refs.search.param);
        },
        // 切换页码
        changePage(pageNum) {
            this.pageNum = pageNum;
            this.$refs.search.search(this.$refs.search.param);
        },
        // 获取表单控件类型
        getFormType(type){
            let options = [
                {
                    label: "普通输入框",
                    value: "string",
                },
                {
                    label: "密码框",
                    value: "password",
                },
                {
                    label: "文本域",
                    value: "textarea",
                },
                {
                    label: "联级选择器",
                    value: "cascader",
                },
                {
                    label: "地区选择器",
                    value: "areaSelector",
                },
                {
                    label: "图标选择器",
                    value: "icon",
                },
                {
                    label: "单选",
                    value: "radio",
                },
                {
                    label: "计数器",
                    value: "number",
                },
                {
                    label: "下拉框",
                    value: "selector",
                },
                {
                    label: "菜单选择器",
                    value: "menuSelector",
                },
                {
                    label: "图片选择器",
                    value: "imageSelector",
                },
                {
                    label: "图片选择器-多选",
                    value: "imagesSelector",
                },
                {
                    label: "日期选择器",
                    value: "date",
                },
                {
                    label: "富文本编辑器",
                    value: "editor",
                },
            ];
            let optionMap = {};
            options.forEach(e=>{
                optionMap[e.value] = e.label;
            });
            if(type){
                return optionMap[type];
            }else{
                return options;
            }
        },
        // 获取查询类型
        getSelectType(type){
            let options = [
                {
                    label: "等于",
                    value: "="
                },
                {
                    label: "不等于",
                    value: "<>"
                },
                {
                    label: "小于",
                    value: "<"
                },
                {
                    label: "小于等于",
                    value: "<="
                },
                {
                    label: "大于",
                    value: ">"
                },
                {
                    label: "大于等于",
                    value: ">="
                },
                {
                    label: "模糊",
                    value: "like"
                },
            ];
            let optionMap = {};
            options.forEach(e=>{
                optionMap[e.value] = e.label;
            });
            if(type){
                return optionMap[type];
            }else{
                return options;
            }
        },
        // 获取列表展示类型
        getListType(type){
            let options = [
                {
                    label: "文字",
                    value: "string",
                },
                {
                    label: "布尔图标",
                    value: "boolean",
                },
                {
                    label: "图片",
                    value: "image",
                },
            ]
            let optionMap = {};
            options.forEach(e=>{
                optionMap[e.value] = e.label;
            });
            if(type){
                return optionMap[type];
            }else{
                return options;
            }
        },
        // 获取排序类型
        getSortType(type){
            let options = [
                {
                    label: "正序",
                    value: "ASC",
                },
                {
                    label: "倒序",
                    value: "DESC",
                },
            ]
            let optionMap = {};
            options.forEach(e=>{
                optionMap[e.value] = e.label;
            });
            if(type){
                return optionMap[type];
            }else{
                return options;
            }
        },
        // 表头样式
        headStyle() {
            return "text-align:center;background:rgb(248,248,249)";
        },
        // 单元格样式
        rowStyle() {
            return "text-align:center";
        },
    }
};
</script>

<style>
</style>